#include "qfloateditor.h"

#include "../property/qabstractproperty.h"

#include <QHBoxLayout>

QFloatEditor::QFloatEditor(QAbstractProperty *property,QWidget *parent):
    QAbstractPropertyEditor(property,parent),
    m_double_spinbox(new QDoubleSpinBox(this))
{
    layout()->addWidget(m_double_spinbox);
    m_double_spinbox->setRange(-9999999,9999999);
    m_double_spinbox->setValue(property->get_value().toDouble());
    connect(m_double_spinbox,SIGNAL(valueChanged(double)),this,SLOT(value_changed(double)));
    setContextMenuPolicy(Qt::NoContextMenu);
}

void QFloatEditor::value_changed(double value)
{
    emit property_changed(value);
}

void QFloatEditor::property_value_changed()
{
    m_double_spinbox->setValue(m_property->get_value().toDouble());
}

qRegisterPropertyEditor("Float",QFloatEditor)
